package com.sxpi.message.controller;

import com.sxpi.common.result.R;
import com.sxpi.message.dto.MessageOrderDto;
import com.sxpi.message.pojo.MessageOrder;
import com.sxpi.message.service.IMessageOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 董伟豪
 * @Date: 2022/10/28 15:54
 */
@RestController
public class MessageOrderController {

    @Autowired
    private IMessageOrderService messageOrderService;

    /**
     * 订单消息保存
     * @param messageOrderDto
     * @return
     */
    @PostMapping("/message/order/create")
    public R saveMessageOrder(@RequestBody MessageOrderDto messageOrderDto){
        MessageOrder messageOrder = new MessageOrder();
        BeanUtils.copyProperties(messageOrderDto,messageOrder);
        boolean save = messageOrderService.save(messageOrder);
        return save ? R.ok() : R.error();
    }

}
